﻿using AutoMapper;
using Pay.Core;
using Pay.Data;
using Pay.DTO;
using Pay.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Service.AutoMapper {

    public class TokenStatisticsMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public TokenStatisticsMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<TokenStatistics, token_statistics_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
                .ForMember(dest => dest.un_confirm_profit, src => src.MapFrom(c => c.UnConfirmProfit))
                .ForMember(dest => dest.confirm_profit, src => src.MapFrom(c => c.ConfirmProfit))
                .ForMember(dest => dest.frozen_profit, src => src.MapFrom(c => c.FrozenProfit))
                .ForMember(dest => dest.frozen_bus_profit, src => src.MapFrom(c => c.FrozenBusProfit))
                .ForMember(dest => dest.bus_deposit, src => src.MapFrom(c => c.BusDeposit))
                .ForMember(dest => dest.bus_depositing, src => src.MapFrom(c => c.BusDepositing))
                .ForMember(dest => dest.bus_deposited, src => src.MapFrom(c => c.BusDeposited))
                .ForMember(dest => dest.total_open_maker, src => src.MapFrom(c => c.TotalOpenMaker))
                .ForMember(dest => dest.total_surplus_open_maker, src => src.MapFrom(c => c.TotalSurplusOpenMaker))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime.ToDateTime()));

            _cfg.CreateMap<token_statistics_dto, TokenStatistics>()
                  .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                  .ForMember(dest => dest.MerchantId, src => src.MapFrom(c => c.merchant_id))
                  .ForMember(dest => dest.UnConfirmProfit, src => src.MapFrom(c => c.un_confirm_profit))
                  .ForMember(dest => dest.ConfirmProfit, src => src.MapFrom(c => c.confirm_profit))
                  .ForMember(dest => dest.FrozenProfit, src => src.MapFrom(c => c.frozen_profit))
                  .ForMember(dest => dest.FrozenBusProfit, src => src.MapFrom(c => c.frozen_bus_profit))
                  .ForMember(dest => dest.BusDeposit, src => src.MapFrom(c => c.bus_deposit))
                  .ForMember(dest => dest.BusDepositing, src => src.MapFrom(c => c.bus_depositing))
                  .ForMember(dest => dest.BusDeposited, src => src.MapFrom(c => c.bus_deposited))
                  .ForMember(dest => dest.TotalOpenMaker, src => src.MapFrom(c => c.total_open_maker))
                  .ForMember(dest => dest.TotalSurplusOpenMaker, src => src.MapFrom(c => c.total_surplus_open_maker))
                  .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time));


        }
    }
}
